package main

import (
	"fmt"
	"math/rand"
)

func main() {
	//1、打印九九乘法表。如果可以要求间隔均匀。
	for i := 1; i < 10; i++ {
		for j := 1; j <= i; j++ {
			fmt.Printf("%d*%d=%d ", j, i, i*j)
			if i*j < 10 {
				fmt.Printf(" ")
			}
		}
		fmt.Println()
	}
	fmt.Println("===============================================================")
	//2、随机生成20以内的20个非0正整数，打印出来。对生成的数值，第单数个（不是索引）累加求和，第偶数个累乘求积。打印结果
	s1, s2 := 0, 1
	for i := 1; i < 21; i++ {
		n := rand.Intn(19) + 1
		if i%2 == 0 {
			s2 = s2 * n
		} else {
			s1 = s1 + n
		}
		fmt.Printf("%d ", n)
	}
	fmt.Printf("\n求和为：%d，乘积为： %d\n", s1, s2)
	fmt.Println("===============================================================")
	//3、打印100以内的斐波那契数列
	n1, n2 := 1, 1
	for i := 1; n1+n2 < 100; i++ {
		if i == 1 || i == 2 {
			fmt.Printf("%d ", 1)
		} else {
			fmt.Printf("%d ", n1+n2)
			n1, n2 = n2, n1+n2
		}
	}
}
